package com.gzw.scm.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.gzw.scm.R;
import com.gzw.scm.bean.PDInfo;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2017/7/25.
 */

public class PDAdapter extends RecyclerView.Adapter{


    private List<PDInfo> list = new ArrayList<>();
    private Context mContext;

    public PDAdapter(List<PDInfo> list, Context context) {
        this.list = list;
        this.mContext = context;

    }



    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_pd, null);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        view.setLayoutParams(lp);
        return new PersonViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, final int i) {
        final PersonViewHolder holder = (PersonViewHolder) viewHolder;
        holder.position = i;
        if(list.get(i).getZt().equals("0")){
            holder.tv_zzxbh.setTextColor(mContext.getResources().getColor(R.color.gray_five));
        }else if(list.get(i).getZt().equals("1")){
            holder.tv_zzxbh.setTextColor(mContext.getResources().getColor(R.color.black));
        }
        holder.tv_zzxbh.setText(list.get(i).getBh());

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class PersonViewHolder extends RecyclerView.ViewHolder {
        public View rootView;
        public TextView tv_zzxbh;
        public int position;

        public PersonViewHolder(View itemView) {
            super(itemView);
            tv_zzxbh = (TextView) itemView.findViewById(R.id.tv_zzxbh);
            rootView = itemView.findViewById(R.id.ll);
        }
    }
}
